package com.shxc.smarttrade.old.push;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.shxc.smarttrade.main.MainActivity;
import com.shxc.smarttrade.MyApplication;
import com.shxc.smarttrade.old.bean.EventDatas;
import com.shxc.smarttrade.old.constants.EventContents;
import com.shxc.smarttrade.old.utils.CloseAllActivity;
import com.shxc.smarttrade.old.utils.Logger;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by Administrator on 2017/11/9.
 */

public class DialogPushActivity extends Activity {

    int status;
    String extra;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        Intent intent = getIntent();
        status = intent.getIntExtra("status", 0);
        extra = intent.getStringExtra("extra");

        Logger.e("status", status + "");
        Logger.e("extra", extra);

        if (status != 0) {
            Intent intents = new Intent(this, MainActivity.class);
            intents.putExtra("extra", extra);
            intents.putExtra("status", status);
            switch (CloseAllActivity.getScreenManager().getStackSize()) {
                case 0:
                    startActivity(intents);
                    break;
                case 1:
                    MyApplication.getInstance().getMainActivity().jump(status);
                    break;
                default:
                    CloseAllActivity.getScreenManager().clearEcxeptMainActivity();
                    EventBus.getDefault().post(new EventDatas(EventContents.DIALOG_PUSH_SEND_MSG, status));
                    break;
            }

        }
        finish();
    }

}
